<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2016/9/17
 * Time: 16:44
 */

namespace Admin\Controller;

use Common\Controller\BaseManageController;

class RecycleController extends BaseManageController
{

    public function index()
    {
        $Model = D("Article");

        $data = $this->lists($Model, array('is_del' => 1));

        foreach ($data as $k => $val) {
            $data[$k] = $Model->_format($val);
        }

        $this->assign('list', $data);
        $this->display();
    }

    public function recover()
    {
        $Model = D("Article");
        $id = I('id');

        $Model->where(array('id' => $id))->save(array('is_del' => 0));
        $Model->cleanCache();
        $this->simpleSuccess('恢复成功！', U('Recycle/index'));
    }

    public function delete()
    {
        $Model = D("Article");
        $id = I('id');
        $Model->delete($id);
        $Model->cleanCache();
        $this->simpleSuccess('删除成功！', U('Recycle/index'));
    }
}